FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name

RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
ENV VPP_INSTALL_SKIP_SYSCTL=1

RUN apt-get update

RUN apt-get install -f -y libcap2-bin libunwind8

COPY \
{% for deb in docker_syncd_vpp_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/

RUN dpkg -i \
{% for deb in docker_syncd_vpp_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %} || apt-get install -f -y

COPY ["start.sh", "/usr/bin/"]

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["critical_processes", "/etc/supervisor/"]

COPY scripts/vpp_hostif.sh /usr/local/bin/
COPY scripts/vpp_init.sh /usr/local/bin/

COPY conf/vpp_init.conf /etc/supervisor/conf.d/
COPY conf/startup.conf.tmpl  /etc/vpp/

## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

ENTRYPOINT ["/usr/local/bin/supervisord"]
